import { Component, OnInit, ViewChild } from '@angular/core';
import { EntityDtoOfInt64, TokenAuthServiceProxy, SFOrderStateDto, SFOrderRouteListDto, SFOrderServiceProxy } from '@shared/service-proxies/service-proxies';
import { ModalDirective } from 'ngx-bootstrap';
import { load } from '@angular/core/src/render3/instructions';
import { Message } from '@angular/compiler/src/i18n/i18n_ast';


@Component({
  selector: 'orderinfoModal',
  templateUrl: './orderinfo.component.html',
  styleUrls: ['./orderinfo.component.css']
})
export class OrderinfoComponent implements OnInit {
  @ViewChild('orderinfoModal') modal: ModalDirective;
  active = false;
  orderNo = '';
  waybillNo = '';
  orderStateCode = '';
  orderStateDesc = '';
  empCode = '';
  empPhone = '';
  netCode = '';
  lastTime = '';
  bookTime = '';
  carrierCode = '';
  routes = new Array<SFOrderRouteListDto>();
  loadingMsg = '';

  constructor(private _sfOrderServiceProxy: SFOrderServiceProxy) { }

  ngOnInit() {
  }
  init() {
    this.orderNo = '';
    this.waybillNo = '';
    this.orderStateCode = '';
    this.orderStateDesc = '';
    this.empCode = '';
    this.empPhone = '';
    this.netCode = '';
    this.lastTime = '';
    this.bookTime = '';
    this.carrierCode = '';
    this.routes = new Array<SFOrderRouteListDto>();


  }
  show(id: number): void {
    if (!id) {
      this.active = true;
    }
    //this.loadingMsg = '正在加载';
    this.init();
    //this.islo
    abp.notify.info('正在加载');
    this.modal.show();
    //获取订单状态
    this._sfOrderServiceProxy.getOrderStateAsync(id)
      .subscribe((ref) => {
        // this.notify.success('操作成功');

        this.waybillNo = ref.waybillNo;
        this.orderStateCode = ref.orderStateCode;
        this.orderStateDesc = ref.orderStateDesc;
        this.empCode = ref.empCode;
        this.empPhone = ref.empPhone;
        this.netCode = ref.netCode;
        this.lastTime = ref.lastTime;
        this.bookTime = ref.bookTime;
        this.carrierCode = ref.carrierCode;
        console.log(ref);


      });
    //获取路由
    this._sfOrderServiceProxy.getRoutePageListAsync(id)
      .subscribe((ref) => {
        // this.notify.success('操作成功');

        this.routes = ref;
        console.log(ref);
      });
  }
  close(): void {
    this.active = false;
    this.modal.hide();
  }

  onShown(): void {

    //document.getElementById('btnPrint').focus();
  }
}
